package com.plugin.recognition.rest;

import com.plugin.recognition.entity.PluginData;
import com.plugin.recognition.service.PluginDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("pluginData")
@Api(description = "识物组件1")
public class PluginDataController {

    @Autowired
    private PluginDataService pluginDataService;

    @ApiOperation(value = "获取数据", notes = "获取数据", produces = "application/json")
    @GetMapping
    public List<PluginData> getAll(){
        return pluginDataService.list();
    }

    @ApiOperation(value = "获取分页数据", notes = "获取分页数据", produces = "application/json")
    @GetMapping("page/{size}/{currentPage}")
    public List<PluginData> getPage(@RequestParam( value = "size") Long size,
                                    @RequestParam( value = "currentPage") Long currentPage){
        return pluginDataService.getByPage(size, currentPage);
    }

    @GetMapping("name/{name}")
    public List<PluginData> getByName(@PathVariable("name") String name){
        return pluginDataService.getByName(name);
    }

    @PostMapping()
    public Boolean save(PluginData pluginData){
        return pluginDataService.save(pluginData);
    }

    @DeleteMapping("{id}")
    public Boolean delete(@PathVariable("id") String id){
        return pluginDataService.removeById(id);
    }

}
